﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Quick.EntityFrameworkCore.Operations;

namespace Quick.EntityFrameworkCore;

public class OperationsFactory : IOperationsFactory
{
    private readonly IServiceProvider _serviceProvider;

    public OperationsFactory(IServiceProvider serviceProvider)
    {
        _serviceProvider = serviceProvider;
    }

    public MigrationOperations<TDbContext> CreateMigrationOperations<TDbContext>(params string[] args) where TDbContext : DbContext
    {
        var logger = _serviceProvider.GetRequiredService<ILogger<MigrationOperations<TDbContext>>>();

        return new MigrationOperations<TDbContext>(logger, _serviceProvider, args);
    }
}
